package com.googlecode.jsimplemarket.model;

import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author john
 */
@Entity
@Table(name = "zzz")

@NamedQueries({
    @NamedQuery(
            name = "ZZZ.queryZZZByMagazinAll",
            query = "select zzz.denumire, zzz.dataAdaugarii, zzz.valoareTotala, zzz.id "
            + "from ZZZ zzz "
            + "where (zzz.dataAdaugarii >= ?1 and zzz.dataAdaugarii < ?2) "
            //+ "and zzz.magazin.id = ?3 "
            + "order by zzz.dataAdaugarii desc "),
    @NamedQuery(
            name = "ZZZ.queryZZZByMagazinSum",
            query = "select sum(zzz.valoareTotala) "
            + "from ZZZ zzz "
            + "where (zzz.dataAdaugarii >= ?1 and zzz.dataAdaugarii < ?2) ")
            //+ "and zzz.magazin.id = ?3 "
            //+ "group by zzz.magazin.id")
})

public class ZZZ extends AbstractEntitate {

    private Utilizator utilizator;
    private Date dataAdaugarii;
    private BigDecimal valoareTotala;
    private String denumire;


    @Column(name = "DATA_ADAUGARII")
    @Temporal(TemporalType.TIMESTAMP)
    public Date getDataAdaugarii() {
        return dataAdaugarii;
    }

    public void setDataAdaugarii(Date dataAdaugarii) {
        this.dataAdaugarii = dataAdaugarii;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "UTILIZATOR_ID")
    public Utilizator getUtilizator() {
        return utilizator;
    }

    public void setUtilizator(Utilizator utilizator) {
        this.utilizator = utilizator;
    }

    @Column(name = "VALOARE_TOTALA")
    public BigDecimal getValoareTotala() {
        return valoareTotala;
    }

    public void setValoareTotala(BigDecimal valoareTotala) {
        this.valoareTotala = valoareTotala;
    }
    
    @Column(name = "DENUMIRE", length = 255)
    public String getDenumire() {
        return denumire;
    }

    public void setDenumire(String denumire) {
        this.denumire = denumire;
    }
    
}
